import http from "@/utils/request";

class CartAPI {
  static getProductList(params) {
    return http.post(`/productInfos/home`, params, {
      custom: {
        auth: true,
        loading: true,
      },
    });
  }
  // test get api
  static getlabelList(params = {}) {
    return http.get("/productInfos/list", {
      custom: {
        auth: true,
        loading: true,
      },
    });
  }
  static getCategoryList(carMakeId) {
    return http.get(`/productCategory/treeStructure`, {
      // params,
      custom: {
        auth: true,
        loading: true,
      },
    });
  }
  // static getCategoryList(carMakeId) {
  // 	return http.get(`/app/homePage/categoryList/${carMakeId}`, {
  // 		// params,
  // 		custom: {
  // 			auth: true,
  // 			loading: true,
  // 		},
  // 	});
  // }

  static getmyCartList(type, id, params) {
    return http.post(`/cart/myCart/${type}/${id}`, params, {
      custom: {
        auth: true,
        loading: true,
      },
    });
  }
  static getDetails(Id) {
    return http.get(`/productInfos/details/${Id}`, {
      // params,
      custom: {
        auth: true,
        loading: true,
      },
    });
  }

  static addCart(params, type) {
    return http.post(`/cart/${type}`, params, {
      custom: {
        auth: true,
        loading: true,
      },
    });
  }
  static deleteCart(params, type) {
    return http.delete(`/cart/${type}`, {
      data: { ...params },
      custom: {
        auth: true,
        loading: true,
      },
    });
  }
  static getCartTotal(id, params) {
    return http.post(`/order/calculateAmount/${id}`, params, {
      custom: {
        auth: true,
        loading: true,
      },
    });
  }
}
export default CartAPI;
